package com.example.smart_city_0829.retrofit;

import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;

import com.example.smart_city_0829.SmartCity;

import retrofit2.Call;
import retrofit2.Response;

/**
 * 自定义请求回调接口，做一些统一的数据操作
 * @param <T>
 */
public abstract class NetCallBack<T> implements retrofit2.Callback<T>{

//    @Override
//    public void onResponse(Call<T> call, Response<T> response) {
//        //检查空异常
//        if (response.body() == null) {
//            onFailure(call,new Throwable(call.request().url()+"===ResponseBody is NULL"));
//        }
//    }

    @Override
    public void onFailure(Call<T> call, Throwable throwable) {
        Toast.makeText(SmartCity.getContext(),"加载失败",Toast.LENGTH_SHORT).show();
        Log.e("NetCallBackInError",throwable.toString());
    }
}
